# -*- coding=utf-8 -*-
import time
import jeepay
from jeepay.app_config import AppConfig

# 配置信息
api_key = "liC2rbnH0SJFWlVzwncM7FZeF6abLNE0s2EFPsK8ZVoTYVddBS3rX39tZX5jIrsdhA4EgNHilhhvqtCNK0quh8SIWBAWxb7HHjHcV4m9SBIptdBzXWLOmisRJF933qAm"
AppConfig.set_mch_no("M1679219294")
AppConfig.set_app_id("6416da5ee4b00bed884be286")
AppConfig.set_api_key(api_key)

"""
支付 API 文档：https://docs.jeequan.com/docs/jeepay/index
"""

print("下单支付")
try:
    create = jeepay.Pay.create(
        mchOrderNo=f"mho{round(time.time() * 1000)}",  # 商户订单号
        wayCode="ALI_BAR",  # 支付方式
        amount=1,  # 支付金额（单位分）
        currency="cny",  # 币种（目前只支持cny）
        clientIp="192.168.1.132",  # 发起支付请求客户端的IP地址
        subject="商品标题",  # 商品标题
        body="商品描述",  # 商品描述
        notifyUrl="",  # 异步通知地址
        returnUrl="",  # 前端跳转地址
        channelExtra="{\"authCode\":\"281901870381096568\"}",  # 渠道扩展参数
        extParam=""  # 商户扩展参数,回调时原样返回
    )
    print(create)
except Exception as e:
    print(e)
